/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package backoffice;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import web.Constants;

/**
 *
 * @author Alejandro
 */
@ManagedBean
@RequestScoped
public class BackofficeControllerBean {

    public String shop() {
        //Cualquier vista no soportada por la tienda para resetear navegacion
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(Constants.NEXT_VIEW, Constants.BC_USERS + Constants.SEPARATOR + 1);

        return "SHOP";
    }

    public String users() {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(Constants.BC_NEXT_VIEW, Constants.BC_USERS + Constants.SEPARATOR + 1);
        return "UPDATE";
    }

    public String items() {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(Constants.BC_NEXT_VIEW, Constants.BC_ITEMS + Constants.SEPARATOR + 1);
        return "UPDATE";
    }

    public String categories() {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(Constants.BC_NEXT_VIEW, Constants.BC_CATEGORIES + Constants.SEPARATOR + 1);
        return "UPDATE";
    }

    public Boolean checkUsers(String view) {
        Boolean res = false;
        if (view != null && !view.isEmpty()) {
            String[] arr = view.split(":");
            res = arr[0].equals(Constants.BC_USERS);
        }
        return res;
    }

    public Boolean checkItems(String view) {
        Boolean res = false;
        if (view != null && !view.isEmpty()) {
            String[] arr = view.split(":");
            res = arr[0].equals(Constants.BC_ITEMS);
        }
        return res;
    }

    public Boolean checkUser(String view) {
        Boolean res = false;
        if (view != null && !view.isEmpty()) {
            String[] arr = view.split(":");
            res = arr[0].equals(Constants.BC_USER);
        }
        return res;
    }

    public Boolean checkItem(String view) {
        Boolean res = false;
        if (view != null && !view.isEmpty()) {
            String[] arr = view.split(":");
            res = arr[0].equals(Constants.BC_ITEM);
        }
        return res;
    }

    public Boolean checkNewItem(String view) {
        Boolean res = false;
        if (view != null && !view.isEmpty()) {
            String[] arr = view.split(":");
            res = arr[0].equals(Constants.BC_NEW_ITEM);
        }
        return res;
    }

    public Boolean checkCategories(String view) {
        Boolean res = false;
        if (view != null && !view.isEmpty()) {
            String[] arr = view.split(":");
            res = arr[0].equals(Constants.BC_CATEGORIES);
        }
        return res;
    }
}
